package exercise11;

import java.util.Arrays;
import java.util.Random;

/**
 * @author Jagger
 * @date 2025/4/16 14:36
 */
public class Test {

    public static void main(String[] args) {
        Sort sort = new Sort();
        // 原数组
        int[] array = createRandomNumber(100_000,10_000);
        // copy数组
        int[] array1 = Arrays.copyOf(array, array.length);
        long start1 = System.currentTimeMillis();
        sort.quickSort(array1);
        System.out.println("quickSort : " + (System.currentTimeMillis()-start1) );

        int[] array2 = Arrays.copyOf(array, array.length);
        long start2 = System.currentTimeMillis();
        sort.shallSort(array2);
        System.out.println("shallSort : " + (System.currentTimeMillis()-start2) );

        int[] array3 = Arrays.copyOf(array, array.length);
        long start3 = System.currentTimeMillis();
        sort.heapSort(array3);
        System.out.println("heapSort : " + (System.currentTimeMillis()-start3) );

        int[] array4 = Arrays.copyOf(array, array.length);
        long start4 = System.currentTimeMillis();
        sort.mergeSort(array4);
        System.out.println("mergeSort : " + (System.currentTimeMillis()-start4) );

        int[] array5 = Arrays.copyOf(array, array.length);
        long start5 = System.currentTimeMillis();
        sort.insertSort(array5);
        System.out.println("insertSort : " + (System.currentTimeMillis()-start5) );

        int[] array6 = Arrays.copyOf(array, array.length);
        long start6 = System.currentTimeMillis();
        sort.bubbleSort(array6);
        System.out.println("bubbleSort : " + (System.currentTimeMillis()-start6) );
    }

    public static void main2(String[] args) {
        int[] array = createRandomNumber(10000, 10000);
        System.out.println("Arrays.toString(array) = " + Arrays.toString(array));
    }


    private static int[] createRandomNumber (int size, int range) {
        int[] array = new int[size];
        for (int i = 0; i < size; i++) {
            array[i] = new Random().nextInt(range);
        }
        return array;
    }

}
